﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="TopProduct.ascx.cs" Inherits="Pub_Module_TopProduct" %>

   
<div width="100%" align="center">
    <table border="0" cellpadding="0" cellspacing="0" width="100%" class="tbl_News">
        <tr>
            <td class="td_TitileNews_590">
            </td>
        </tr>
        <tr>
            <td class="td_Content_590">
                <table width="100%" style="padding-left: 10px; padding-right: 15px" cellpadding="0"
                    cellspacing="0">
                    <tr>
                        <td align="center" height="45px" valign="middle">
                            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                <tr>
                                    <td class="td_Middle_L">
                                    </td>
                                    <td class="td_Middle_C" align="center">
                                        <asp:Label ID="Label1" runat="server" Text="NHỮNG SẢN PHẨM MỚI NHẤT" CssClass="lbl_TitileNews_590"></asp:Label>
                                    </td>
                                    <td class="td_Middle_R">
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td style="background-color: White">
                            <div id="header">
                                <asp:DataList ID="dtlThumbnail" runat="server" RepeatDirection="Horizontal" Width="100%"
                                    BorderWidth="0px" DataKeyField="PdID" CellPadding="0" CellSpacing="0" OnItemDataBound="dtlThumbnail_ItemDataBound"
                                    OnItemCommand="dtlThumbnail_ItemCommand" RepeatColumns="3">
                                    <ItemStyle Wrap="False" />
                                    <ItemTemplate>
                                   <div class="navbaraa"> 
                                        <table border="0" cellpadding="0" cellspacing="0" style="width: 100%;" class="tbl_line"
                                            onmouseover="this.style.backgroundImage='url(Images/Body/HNB.JPG)'"
                                            onmouseout="this.style.backgroundImage=''">
                                            <tr>
                                                <td class="td_line-x" colspan="3" runat="server" id="td_top" visible="false">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="td_line-y" id="td_left" runat="server" visible="false">
                                                </td>
                                                <td style="vertical-align: top">
                                                    <a name="PageIndex_<%# Eval("PDID").ToString().Trim() %>"></a>
                                                    <table border="0" cellpadding="0" cellspacing="0" style="width: 100%;" class="tbl_Product">
                                                        <tr>
                                                            <td align="left" colspan="1" nowrap="nowrap">
                                                                <asp:Label ID="lblMaSP" Visible="false" runat="server" Text='<%# Eval("PDID") %>'></asp:Label>&nbsp;</td>
                                                        </tr>
                                                        <tr>
                                                            <td align="center" nowrap="nowrap" class="td_ImgProduct" valign="top">
                                                                <asp:Image ID="imgProductStall" runat="server" Style="text-align: left;" TenSP='<%# Eval("PDName") %>'
                                                                    CssClass="img_Product" onclick="OpenPopUpTooltip(this)" />
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td align="left" colspan="1" nowrap="nowrap" valign="top">
                                                                <table width="100%" cellpadding="0" cellspacing="0">
                                                                    <tr>
                                                                        <td valign="top" align="center">
                                                                            <a href="<%=ResolveUrl("~")%>Shopping/Stall/ProductDetail.aspx?PDID=<%# Eval("PDID")  %>"
                                                                                class="lbl_MostTitleProduct" style="cursor: pointer">
                                                                                <asp:Label ID="lblTenSP" runat="server" CssClass="lbl_MostTitleProduct" Text='<%# Eval("PDName") %>'
                                                                                    Width="160px"></asp:Label></a></td>
                                                                    </tr>
                                                                </table>
                                                                <asp:Panel ID="pnlKindNo" runat="server" Width="100%">
                                                                    <table width="100%">
                                                                        <tr>
                                                                            <td style="padding-left: 5px">
                                                                                <asp:Label ID="Label3" runat="server" CssClass="lbl_TitlePrice" Text="Bảo hành: "></asp:Label>
                                                                                <asp:Label ID="Label4" runat="server" CssClass="lbl_Properties" Text='<%# Eval("Warranty")  %>'></asp:Label>
                                                                                <asp:Label ID="Label3434" runat="server" CssClass="lbl_TitlePrice" Text="Tháng"></asp:Label>&nbsp;</td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td style="padding-left: 5px;" id="tdPrice" runat="server">
                                                                                <asp:Label ID="Label1" runat="server" CssClass="lbl_TitlePrice" Text="Giá: "></asp:Label>
                                                                                <asp:Label ID="lblDongia" runat="server" CssClass="lbl_Price" Text='<%# Eval("Price")  %>'></asp:Label>
                                                                                <asp:Label ID="Label6" runat="server" CssClass="lbl_Rate" Text='<%# Eval("Rate")  %>'
                                                                                    ForeColor="Navy"></asp:Label>
                                                                            </td>
                                                                        </tr>
                                                                        <tr id="trSaleOf" runat="server" visible="false">
                                                                            <td style="padding-left: 5px">
                                                                                <asp:Label ID="Label222" runat="server" CssClass="lbl_TitlePrice" Text="Chỉ còn: "></asp:Label>
                                                                                <asp:Label ID="lblDiscountPrice" runat="server" CssClass="lbl_Price" Text='<%# Eval("DiscountPrice")  %>'></asp:Label>
                                                                                <asp:Label ID="Label923" runat="server" CssClass="lbl_Rate" Text='<%# Eval("DiscountRate")  %>'
                                                                                    ForeColor="Navy" Font-Size="13px"></asp:Label>
                                                                            </td>
                                                                        </tr>
                                                                    </table>
                                                                </asp:Panel>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td align="left" nowrap="nowrap">
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td align="left" nowrap="nowrap">
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td align="right" colspan="1" nowrap="nowrap">
                                                                <asp:Image ID="imgHot" runat="server" Visible="false" />
                                                                <asp:ImageButton runat="server" ID="btnIDetail" ImageUrl="~/Images/Icon/detail.gif" /><asp:ImageButton
                                                                    runat="server" ID="btnISelect" ImageUrl="~/Images/Icon/buy.gif" /><asp:ImageButton
                                                                        runat="server" ID="btnICancel" ImageUrl="~/Images/Icon/cancel.GIF" Visible="False" /></td>
                                                        </tr>
                                                    </table>
                                                </td>
                                                <td class="td_line-y" style="width: 2px" id="td_right" runat="server">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="td_line-x" colspan="3">
                                                </td>
                                            </tr>
                                        </table></div>
                                    </ItemTemplate>
                                </asp:DataList>
                            </div>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td align="right" class="td_Content_Footer_590" style="padding-right: 25px">
            </td>
        </tr>
    </table>
</div>
<div class='product_popup' id="divTooltip" onmouseover="OpenDivPopUpTooltip()" onmouseout="HidePopUpTooltip()"
    onclick="HidePopUpTooltip()" style="cursor: pointer">
    <table class="tbl_popup" cellpadding="0" cellspacing="0">
        <tr>
            <td>
                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                    <tr>
                        <td class="td_Middle_L_Pop">
                        </td>
                        <td class="td_Middle_C_Pop" align="left" id="tdProductTitle">
                        </td>
                        <td class="td_Middle_R_Pop">
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td nowrap="nowrap" rowspan="2" class="product_detail_popup" id="tdProductDetail"
                style="text-align: center">
            </td>
        </tr>
    </table>
</div>

<script language="javascript" type="text/javascript">
  function OpenPopUpTooltip(obj)
     {       
       var tdProductDetail=document.getElementById("tdProductDetail");    
       var tdProductTitle=document.getElementById("tdProductTitle");           
       var divTooltip=document.getElementById("divTooltip");
       divTooltip.style.visibility="visible" ;
       var sleft=ObjectPosition(obj)[0];      
       var stop=ObjectPosition(obj)[1]-(divTooltip.clientHeight/2); 
       divTooltip.style.left = sleft-obj.clientWidth + 'px';
       divTooltip.style.top =  stop-obj.clientHeight+ 'px';   
      // tdProductDetail.innerHTML="<div style='padding:200 200 200 200'><img src='http://localhost:1038/WebShop/Images/Icon/loadingPD.gif' border='0'></div>";
      
       var sSrc=obj.src;

	   var Index=parseInt(sSrc.lastIndexOf("/"));
	   var iLength=parseInt(sSrc.length);
	   var filename=sSrc.substr(Index+1,iLength);

       if(filename=='Noimages.gif')
       {
            divTooltip.style.visibility="hidden" ;
            return;
       }
       var sTenSP=obj.getAttribute("TenSP");          
        tdProductTitle.innerHTML=sTenSP; 
        var img="<img src="+sSrc+">"  
          
        tdProductDetail.innerHTML=img;
      //var img="<img src="+sSrc+" width="+sWidth+" height="+sHeight+">"       
     }
     function OpenEventPopUpTooltip(e,lbl)
     { 
    
       obj=lbl.nextSibling ;
       var sSrc=obj.src;       
       var divTooltip=document.getElementById("divTooltip");
        divTooltip.style.visibility="visible" ;    
       var sleft=ObjectPosition(obj)[0];    
        var stop=ObjectPosition(obj)[1]-(divTooltip.clientHeight/2);        
      // var stop=ObjectPosition(obj)[1]-100;   
    //alert(clientHeight)
    //alert(obj.clientHeight);
       
	   var Index=parseInt(sSrc.lastIndexOf("/"));
	   var iLength=parseInt(sSrc.length);
	   var filename=sSrc.substr(Index+1,iLength);

       if(filename=='Noimages.gif')
       {
            divTooltip.style.visibility="hidden" ;
            return;
       }

        var tdProductDetail=document.getElementById("tdProductDetail");    
        var tdProductTitle=document.getElementById("tdProductTitle");           
              
        
      	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
		if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 
	
		var leftPos = e.clientX + 20;
		if(leftPos<0)leftPos = 0;
        divTooltip.style.left = leftPos + 'px';
        divTooltip.style.top =  stop+ 'px';    
       // divTooltip.style.top = e.clientY + 'px';
             
        
        tdProductTitle.innerHTML=lbl.innerHTML;
       // var img="<img src="+sSrc+" width="+sWidth+" height="+sHeight+">"  
        var img="<img src="+sSrc+">";
        
        tdProductDetail.innerHTML=img;
        //divTooltip.style.top = e.clientY - obj.offsetHeight- (divTooltip.clientHeight/2) + st + 'px';
     }    
     
     function HidePopUpTooltip()
     { 
             var divTooltip=document.getElementById("divTooltip");
             divTooltip.style.visibility="hidden"
     }
     
     function OpenDivPopUpTooltip()
     { 
             var divTooltip=document.getElementById("divTooltip");
             divTooltip.style.visibility="visible"
     }
     
     
     function ObjectPosition(obj) 
     {
          var curleft = 0;
          var curtop = 0;
          if (obj.offsetParent) {
                do {
                      curleft += obj.offsetLeft;
                      curtop += obj.offsetTop;
                } while (obj = obj.offsetParent);
          }
          return [curleft,curtop];
	}
</script>

